package com.example.gybicycle.service;

import java.util.Date;
import com.example.gybicycle.common.entity.Result;
import com.example.gybicycle.common.enums.NumType;
import com.example.gybicycle.common.sql.CrudService;
import com.example.gybicycle.common.util.NumberUtil;
import com.example.gybicycle.entity.MemberInsure;
import com.example.gybicycle.dao.MemberInsureDao;
import com.example.gybicycle.entity.MemberOrder;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class MemberInsureService extends CrudService<MemberInsureDao, MemberInsure> {
    @Override
    public MemberInsure get(String id) {
        MemberInsure table=super.get(id);
        return table;
    }
    public Result save(MemberInsure entity,String loginId){
        int num=0;
        if(entity.getId()==null){
           
            num=dao.insert(entity);
        }else {
           
            num=dao.update(entity);
        }
        if(num>0)
            return Result.success(entity);
        else 
            return Result.fail("保存失败");
    }

    @Override
    public int insert(MemberInsure entity) {
        entity.setId(NumberUtil.getNum(NumType.INSURE));
        entity.setState(0);
        int num=super.insert(entity);
        return  num;
    }

    @Override
    public int insertByList(List<MemberInsure> list) {
        for(MemberInsure entity:list){
            entity.setState(0);
            entity.setId(NumberUtil.getNum(NumType.INSURE));
        }
        return super.insertByList(list);
    }

    public List<MemberInsure> findList(MemberInsure entity){
        List<MemberInsure> list=super.findList(entity);
        return list;
    }


}